<template>
    <div class="table-operator">
        <a-button shape="round" size="small" type="primary" icon="eye" @click="print(1)">打印预览</a-button>
        <a-button shape="round" size="small" type="primary" icon="printer" @click="print(2)">打印</a-button>
        <a-button shape="round" size="small" type="primary" icon="setting" @click="print(3)">打印维护</a-button>
    </div>
</template>

<script>
import {getLodop} from '/public/static/clodop/LodopFuncs'
export default {
    name:'clodop',
    data(){
        return{
            LODOP:null,
        }
    },
    mounted(){
        this.$nextTick(() => {
          
        });
    },
    methods:{
        print(type){
            this.createOneFormPage()
            if(type==1){
                //打印预览

                //设置打印预览页面大小，如果不加则全屏
                this.LODOP.SET_PREVIEW_WINDOW(0,0,0,800,600,"");
                
                this.LODOP.PREVIEW()
            }else if(type==2){
                //直接打印
               this.LODOP.PRINT()
            }else if(type==3){
                //打印维护,免费用不了
                // this.createOneFormPage()
                this.LODOP.PRINT_SETUP()
            }
        },
        createOneFormPage(){
            //出库单
            //http://www.lodop.net/demolist/PrintSampleA1.html 通过此页面进行设计

            
            this.LODOP=getLodop()
            this.LODOP.SET_PRINT_MODE("RESELECT_PRINTER",true)//允许重选打印机
            this.LODOP.SET_PRINT_MODE("RESELECT_ORIENT",true)//允许重选纸张方向
            this.LODOP.SET_PRINT_MODE("RESELECT_PAGESIZE",true)//允许重选纸张
            this.LODOP.SET_PRINT_MODE("RESELECT_COPIES",true)//允许重选份数
            

            LODOP.ADD_PRINT_TEXT(12,260,275,30,"装 备 器 材 入 库 单");
            LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.SET_PRINT_STYLEA(0,"Bold",1);
            LODOP.ADD_PRINT_TEXT(47,139,81,20,"编 号:");
            LODOP.ADD_PRINT_TEXT(47,537,81,20,"日 期:");
            LODOP.ADD_PRINT_TEXT(85,31,100,20,"名称");
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.ADD_PRINT_TEXT(85,181,50,20,"单位");
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.ADD_PRINT_TEXT(85,231,50,20,"数量");
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.ADD_PRINT_TEXT(85,281,258,20,"入库原因");
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.ADD_PRINT_TEXT(85,539,100,20,"规格型号");
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
            LODOP.ADD_PRINT_TEXT(85,639,100,20,"物资编码");
            LODOP.SET_PRINT_STYLEA(0,"Alignment",2);

            
            LODOP.ADD_PRINT_LINE(78,30,76,738,0,0);//最上面的横线线
            LODOP.ADD_PRINT_LINE(103,30,103,738,0,0);//第二条横线
            let hLineTop = 103;
            let rowHeight = 25;
            let hTextTop = 110;
            //画物料横线
            for(var i=0;i<5;i++){
                hLineTop = hLineTop+rowHeight
                LODOP.ADD_PRINT_LINE(hLineTop,30,hLineTop,738,0,0);
                this.printContent(hTextTop)
                hTextTop = hTextTop+rowHeight
            }
            //画备注
            hLineTop = hLineTop+rowHeight
            LODOP.ADD_PRINT_LINE(hLineTop,30,hLineTop,738,0,0);

            //画竖线
            LODOP.ADD_PRINT_LINE(hLineTop,30,76,30,0,0);//最左侧竖线
            LODOP.ADD_PRINT_LINE(hLineTop-25,180,76,180,0,0);//第二条竖线，从左向右
            LODOP.ADD_PRINT_LINE(hLineTop-25,230,76,230,0,0);//第三条横线
            LODOP.ADD_PRINT_LINE(hLineTop-25,280,76,280,0,0);//第四条
            LODOP.ADD_PRINT_LINE(hLineTop-25,538,76,538,0,0);//第五条线
            LODOP.ADD_PRINT_LINE(hLineTop-25,638,76,638,0,0);//第六条竖线
            LODOP.ADD_PRINT_LINE(hLineTop,738,76,738,0,0); //第七条竖线

            LODOP.ADD_PRINT_TEXT(hLineTop+25,100,100,20,"单位负责人:");
            LODOP.ADD_PRINT_TEXT(hLineTop+25,350,100,20,"保管员:");
            LODOP.ADD_PRINT_TEXT(hLineTop+25,550,100,20,"经办人:");

        



            


            //二维码（TOP,LEFT,WIDTH,HEIGHT）
           // this.LODOP.ADD_PRINT_BARCODE(10,50,150,150,"QRCode","11111");
        },
        printContent(hTextTop){
         LODOP.ADD_PRINT_TEXT(hTextTop,31,100,20,"1名称1111111");
        LODOP.ADD_PRINT_TEXT(hTextTop,181,50,20,"1单位");
        LODOP.ADD_PRINT_TEXT(hTextTop,231,50,20,"1数量");
        LODOP.ADD_PRINT_TEXT(hTextTop,281,258,20,"1原因");
        LODOP.ADD_PRINT_TEXT(hTextTop,539,100,20,"1规格");
    }
    },
    

}
</script>